import React, { useContext } from 'react'
import context from '../context'
function Com () {
  // 子组件中直接通过context拿到dispatch，出发reducer操作state
  const { dispatch, state } = useContext(context)
  return (
    <p>
      组件2。输入age
        <input value={state.age} onChange={(e) => dispatch({ type: 'age', payload: e.target.value })} />
    </p>

  )
}

export default Com
